package 第一章基础算法.二分.id789数的范围;

import java.util.Scanner;

/**
 * 二分左右边界模板
 * 注意写法，l=mid， mid = l +(r-l+1>>1) 需要+1防止死循环
 */
public class Main {

    public static void main(String[] args) {
        //处理输入
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        int []nums = new int[n];
        for(int i = 0;i<n;i++){
            nums[i] = scanner.nextInt();
        }

        while (q-->0){
            int num = scanner.nextInt();
            //二分查找
            int res1 = binarySearch_L(nums,0,n-1,num);
            int res2 = binarySearch_R(nums,0,n-1,num);
            //处理输出
            if(res1 == -1 && res2 == -1)System.out.println("-1 -1");
            else System.out.println(res1+ " " + res2);
        }

    }
    //找小于等于num的第一个数(左边界)
    //相等要往左边找
    public static int binarySearch_L(int[]nums, int l, int r,int num){
        int n = nums.length;
        while (l < r){
            int mid = l + (r-l>>1);
            if(nums[mid] < num){
                l = mid + 1;
            }else
                r = mid;
        }
        if(nums[l] == num)return l;
        return -1;

    }
    //找大于等于num的第一个数(右边界)
    //相等要往右边找
    public static int binarySearch_R(int[]nums, int l ,int r, int num){
        int n = nums.length;
        while (l < r){
            int mid = l + (r-l+1>>1);
            if(nums[mid] <= num){
                l = mid;
            }else
                r = mid - 1;
        }
        if(nums[l] == num)return l;
        return -1;
    }
}